package com.jlboot.app.common.router;

import cn.dev33.satoken.jfinal.SaAnnotationInterceptor;
import com.jfinal.config.Routes;
import com.jlboot.app.admin.interceptor.ReadonlyInterceptor;
import com.jlboot.app.common.controller.FileController;
import com.jlboot.app.common.interceptor.CommonGlobalInterceptor;
import com.jlboot.app.openapi.controller.OpenApiController;
import com.jlboot.core.ConfigUtil;

/**
 * Created by 51594 on 2022/7/28.
 */
public class CommonRoutes extends Routes {

    public void config() {

        //拦截器顺序不能先添加在在最外层，用于全局异常捕捉
        addInterceptor(new CommonGlobalInterceptor());
        //开启注解方式权限验证
        addInterceptor(new SaAnnotationInterceptor());
        if (ConfigUtil.READONLY()) addInterceptor(new ReadonlyInterceptor());

        add("OpenApi", OpenApiController.class);
        add("/file", FileController.class);

    }
}
